<?php

function rpc( $json_request ) {
    global $PARAPARA;

    $req_param = $json_request->param;

    if(!$req_param) {
        return new RPC_Error($json_request->operation, "PARAM", "No params");
    }

    $message_id = $req_param->message_id;
    if(!is_numeric( $message_id ) )
        return new RPC_Error($json_request->operation, "PARAM", "No message_id");

    $body = $PARAPARA->get_message_body( $message_id );
    if(!$body )
        return new RPC_Error($json_request->operation, "NOT_FOUND", "Body not found");


    $rpc_retval = 
        array( 
            'html'   => $body->as_html( array() ),
            'msg_id' => $body->id
            );

    return new RPC_Response( $json_request->operation, $rpc_retval );


}

return rpc( $json_request );


?>